package ui.components;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
//import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import javax.swing.JPanel;

public class ImageControl extends JPanel {
	protected ImageList imagelist;
	protected int currentImage;
	protected int width;
	protected int height;

	protected ImageControl( ) {
		
	}
	public ImageControl( ImageList images, int width, int height ) {
		this.imagelist = images;
		this.width = width;
		this.height = height;
		this.setSize( width, height);
		currentImage = 0;
		
		addMouseListener(
			new MouseAdapter( ) {
				public void mousePressed( MouseEvent e ) {
					System.out.println( "event" );
					mouseDown( e );
				}
				public void mouseReleased( MouseEvent e ) {
					mouseUp( e );
					repaint();
				}
			}
		);
	}
	public void paintComponent( Graphics g ) {
		if (imagelist.image( currentImage ) != null) {
			g.clearRect( 0, 0, width, height);
			g.setColor( this.getBackground( ) );
			g.fillRect(0, 0, width, height);
			g.drawImage( imagelist.image( currentImage ), 0, 0, this );
		}
    }
	public void mouseDown( MouseEvent e ) {
		System.out.println( "mousedown" );
	}
	public void mouseUp( MouseEvent e ) {
		
	}
	public int getWidth( ) {
		return width;
	}
	public int getHeight( ) {
		return height;
	}
}
